 /*
	Table: User
	Schema: core
	Filegroup: FG_CORE
*/

CREATE TABLE [core].[User]
(
	/* Primary Key */
	PK_User INT NOT NULL IDENTITY,
	
	[Comment] NVARCHAR(256),
	[EMail] NVARCHAR(256),
	[IsApproved] BIT NOT NULL,
	[IsLockedOut] BIT NOT NULL,
	[IsOnline] BIT NOT NULL,
	[LastActivityDate] DATETIME,
	[LastLockoutDate] DATETIME,
	[LastLoginDate] DATETIME,
	[LastPasswordChangedDate] DATETIME,
	[UserName] NVARCHAR(256) NOT NULL,

	/* Default Columns */
	CreatedAt DATETIME NOT NULL,
	CreatedBy NVARCHAR(256) NOT NULL,
	CreatedFromSource NVARCHAR(256) NOT NULL,
	ModifiedAt DATETIME NOT NULL,
	ModifiedBy NVARCHAR(256) NOT NULL,
	ModifiedFromSource NVARCHAR(256) NOT NULL
) ON [FG_CORE]
GO

ALTER TABLE [core].[User]
	ADD CONSTRAINT PK_User
		PRIMARY KEY(PK_User) ON FG_INDEXES
GO

ALTER TABLE [core].[User]
	ADD CONSTRAINT DEF_core_User_CreatedAt
		DEFAULT GETDATE() FOR CreatedAt
GO

ALTER TABLE [core].[User]
	ADD CONSTRAINT DEF_core_User_IsApproved
		DEFAULT 0 FOR [IsApproved]
GO

ALTER TABLE [core].[User]
	ADD CONSTRAINT DEF_core_User_IsLockedOut
		DEFAULT 0 FOR [IsLockedOut]
GO

ALTER TABLE [core].[User]
	ADD CONSTRAINT DEF_core_User_IsOnline
		DEFAULT 0 FOR [IsOnline]
GO

CREATE UNIQUE INDEX UIDX_core_User_UserName
	ON [core].[User](UserName)